package com.youngcms.controller.base;

import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import com.youngcms.bean.Channel;
import com.youngcms.service.ChannelService;
import com.youngcms.vo.QueryResult;

@Controller
@RequestMapping("/front/")
public class TestController extends FrontBaseController {
	
	@Autowired
	private ChannelService channelService;
	
	@RequestMapping("test")
	public ModelAndView test() {
		ModelAndView mnv = new ModelAndView();
		QueryResult<Channel> queryResult= null;
		//QueryResult<Channel> queryResult= channelService.listByHql("select new Channel(c.id, c.pId,c.name,c1.name as pName) from Channel c,Channel c1 where c.id=c1.pId");
		for (Channel channel : queryResult.getQueryResult()) {
			System.out.println(channel.getId());
			System.out.println(channel.getName());
		}
		System.out.println(queryResult.getCount());
		return mnv;
	}
	
	@RequestMapping("test1")
	public ModelAndView test1() {
		ModelAndView mnv = new ModelAndView();
		QueryResult<Channel> queryResult= null;
		//QueryResult<Channel> queryResult= channelService.listBySql("select a.id,a.name,b.id,b.name from tb_channel a,tb_channel b where a.pId=b.id");
		for (Map<String, Object> map : queryResult.getQueryResultMap()) {
			System.out.println(map.get("id"));
			System.out.println(map.get("name"));
		}
		System.out.println(queryResult.getCount());
		return mnv;
	}
	
	

}
